home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / VARARGS.H < prev    next >
C/C++ Source or Header  |  1993-11-23  |  1KB  |  53 lines

  1. /***
  2. *varargs.h - XENIX style macros for variable argument functions
  3. *
  4. *   Copyright (c) 1985-1992, Microsoft Corporation.  All rights reserved.
  5. *
  6. *Purpose:
  7. *   This file defines XENIX style macros for accessing arguments of a
  8. *   function which takes a variable number of arguments.
  9. *   [System V]
  10. *
  11. ****/
  12.  
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif 
  16.  
  17. #ifdef _WINDLL
  18. #define _FARARG_ __far
  19. #else 
  20. #define _FARARG_
  21. #endif 
  22.  
  23. #if (_MSC_VER <= 600)
  24. #define __far       _far
  25. #endif 
  26.  
  27. #ifdef __STDC__
  28. #error varargs.h incompatible with ANSI (use stdarg.h)
  29. #endif 
  30.  
  31. #ifndef _VA_LIST_DEFINED
  32. typedef char _FARARG_ *va_list;
  33. #define _VA_LIST_DEFINED
  34. #endif 
  35.  
  36. /*
  37.  * define a macro to compute the size of a type, variable or expression,
  38.  * rounded up to the nearest multiple of sizeof(int). This number is its
  39.  * size as function argument (Intel architecture). Note that the macro
  40.  * depends on sizeof(int) being a power of 2!
  41.  */
  42.  
  43. #define _INTSIZEOF(n)    ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  44.  
  45. #define va_dcl va_list va_alist;
  46. #define va_start(ap) ap = (va_list)&va_alist
  47. #define va_arg(ap,t) ( *(t _FARARG_ *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  48. #define va_end(ap) ap = (va_list)0
  49.  
  50. #ifdef __cplusplus
  51. }
  52. #endif 
  53.